﻿using DotXxlJob.Core;

namespace XxlJobDotNetCore.Middleware
{
    /// <summary>
    /// 请求日志中间件
    /// </summary>
    public class HttpLogMiddleware
    {
        private readonly RequestDelegate _next;
        private readonly ILogger _logger;
        public HttpLogMiddleware( RequestDelegate next, ILoggerFactory loggerFactory)
        {
            _next = next;
            _logger = loggerFactory.CreateLogger(GetType());
        }

        public async Task Invoke(HttpContext context)
        {
            _logger.LogInformation($"Http Request Path:{context.Request.Path}.");
            await _next.Invoke(context);
        }
    }
}
